load("@rules_java//java:defs.bzl", "java_library")
load("//:cel_android_rules.bzl", "cel_android_local_test")
load("//:testing.bzl", "junit4_test_suites")

package(
    default_applicable_licenses = ["//:license"],
    default_testonly = True,
)

ANDROID_TESTS = [
    "CelLiteRuntimeAndroidTest.java",
]

java_library(
    name = "tests",
    testonly = 1,
    srcs = glob(
        ["*.java"],
        # keep sorted
        exclude = [
            "CelLiteInterpreterTest.java",
            "CelValueInterpreterTest.java",
            "InterpreterTest.java",
        ] + ANDROID_TESTS,
    ),
    deps = [
        "//:auto_value",
        "//:java_truth",
        "//bundle:cel",
        "//common:cel_ast",
        "//common:cel_descriptors",
        "//common:cel_exception",
        "//common:cel_source",
        "//common:compiler_common",
        "//common:container",
        "//common:error_codes",
        "//common:options",
        "//common:proto_v1alpha1_ast",
        "//common:runtime_exception",
        "//common/ast",
        "//common/internal:cel_descriptor_pools",
        "//common/internal:converter",
        "//common/internal:default_message_factory",
        "//common/internal:dynamic_proto",
        "//common/internal:proto_message_factory",
        "//common/internal:proto_time_utils",
        "//common/internal:well_known_proto",
        "//common/types",
        "//common/types:cel_v1alpha1_types",
        "//common/types:message_type_provider",
        "//common/values",
        "//common/values:cel_byte_string",
        "//common/values:cel_value_provider",
        "//common/values:proto_message_lite_value_provider",
        "//compiler",
        "//compiler:compiler_builder",
        "//extensions",
        "//extensions:optional_library",
        "//parser:macro",
        "//parser:unparser",
        "//runtime",
        "//runtime:activation",
        "//runtime:dispatcher",
        "//runtime:evaluation_exception_builder",
        "//runtime:evaluation_listener",
        "//runtime:function_binding",
        "//runtime:function_overload_impl",
        "//runtime:interpretable",
        "//runtime:interpreter",
        "//runtime:interpreter_util",
        "//runtime:late_function_binding",
        "//runtime:lite_runtime",
        "//runtime:lite_runtime_factory",
        "//runtime:proto_message_activation_factory",
        "//runtime:proto_message_runtime_equality",
        "//runtime:proto_message_runtime_helpers",
        "//runtime:runtime_equality",
        "//runtime:runtime_helpers",
        "//runtime:standard_functions",
        "//runtime:type_resolver",
        "//runtime:unknown_attributes",
        "//runtime:unknown_options",
        "//testing/protos:message_with_enum_cel_java_proto",
        "//testing/protos:message_with_enum_java_proto",
        "//testing/protos:multi_file_cel_java_proto",
        "//testing/protos:multi_file_java_proto",
        "//testing/protos:single_file_java_proto",
        "//testing/protos:test_all_types_cel_java_proto2",
        "//testing/protos:test_all_types_cel_java_proto3",
        "@cel_spec//proto/cel/expr/conformance/proto2:test_all_types_java_proto",
        "@cel_spec//proto/cel/expr/conformance/proto3:test_all_types_java_proto",
        "@com_google_googleapis//google/api/expr/v1alpha1:expr_java_proto",
        "@com_google_googleapis//google/rpc/context:attribute_context_java_proto",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
        "@maven//:com_google_protobuf_protobuf_java_util",
        "@maven//:com_google_testparameterinjector_test_parameter_injector",
        "@maven//:com_google_truth_extensions_truth_proto_extension",
        "@maven//:junit_junit",
        "@maven//:org_jspecify_jspecify",
        "@maven_android//:com_google_protobuf_protobuf_javalite",
    ],
)

java_library(
    name = "interpreter_test",
    testonly = 1,
    srcs = [
        "InterpreterTest.java",
    ],
    deps = [
        #         "//java/com/google/testing/testsize:annotations",
        "//testing:base_interpreter_test",
        "@maven//:junit_junit",
        "@maven//:com_google_testparameterinjector_test_parameter_injector",
    ],
)

java_library(
    name = "cel_value_interpreter_test",
    testonly = 1,
    srcs = [
        "CelValueInterpreterTest.java",
    ],
    deps = [
        #         "//java/com/google/testing/testsize:annotations",
        "//testing:base_interpreter_test",
        "@maven//:junit_junit",
        "@maven//:com_google_testparameterinjector_test_parameter_injector",
    ],
)

cel_android_local_test(
    name = "android_tests",
    srcs = ANDROID_TESTS,
    test_class = "dev.cel.runtime.CelLiteRuntimeAndroidTest",
    deps = [
        "//:java_truth",
        "//common:cel_ast_android",
        "//common:options",
        "//common/internal:proto_time_utils_android",
        "//common/values:cel_byte_string",
        "//common/values:cel_value_provider_android",
        "//common/values:proto_message_lite_value_provider_android",
        "//extensions:lite_extensions_android",
        "//extensions:sets_function",
        "//runtime:evaluation_exception",
        "//runtime:function_binding_android",
        "//runtime:late_function_binding_android",
        "//runtime:lite_runtime_android",
        "//runtime:lite_runtime_factory_android",
        "//runtime:lite_runtime_impl_android",
        "//runtime:standard_functions_android",
        "//runtime:unknown_attributes_android",
        "//runtime/standard:equals_android",
        "//runtime/standard:int_android",
        "//testing/protos:test_all_types_cel_java_proto2_lite",
        "//testing/protos:test_all_types_cel_java_proto3_lite",
        "//testing/src/main/java/dev/cel/testing/compiled:compiled_expr_utils_android",
        "@cel_spec//proto/cel/expr:checked_java_proto_lite",
        "@cel_spec//proto/cel/expr/conformance/proto2:test_all_types_java_proto_lite",
        "@cel_spec//proto/cel/expr/conformance/proto3:test_all_types_java_proto_lite",
        "@maven//:com_google_testparameterinjector_test_parameter_injector",
        "@maven_android//:com_google_guava_guava",
        "@maven_android//:com_google_protobuf_protobuf_javalite",
    ],
)

java_library(
    name = "cel_lite_interpreter_test",
    testonly = 1,
    srcs = [
        "CelLiteInterpreterTest.java",
    ],
    deps = [
        "//common/values:proto_message_lite_value_provider",
        "//extensions:optional_library",
        "//runtime",
        "//testing:base_interpreter_test",
        "//testing/protos:test_all_types_cel_java_proto2",
        "//testing/protos:test_all_types_cel_java_proto3",
        "@maven//:com_google_testparameterinjector_test_parameter_injector",
        "@maven//:junit_junit",
    ],
)

junit4_test_suites(
    name = "test_suites",
    shard_count = 4,
    sizes = [
        "small",
        "medium",
    ],
    src_dir = "src/test/java",
    deps = [
        ":cel_lite_interpreter_test",
        ":cel_value_interpreter_test",
        ":interpreter_test",
        ":tests",
    ],
)
